<template>
	<div v-for="(v, i) in flows" :key="i">
		<a-card :title="v.dictLabel" style="width: 100%" :bordered="false" v-if="v.childs.length > 0">
			<div class="allApply">
				<div class="siggleAppy" v-for="(vc, ic) in v.childs" :key="ic">
					<iconCard :icon="vc.flowIcon" :label="vc.flowTitle" @click="flowApply(vc)" />
				</div>
			</div>
		</a-card>
	</div>
	<dtForm ref="dtFromRef" :isPreview="false" />
	<preForm ref="preFormRef" />
</template>
<script setup name="beginFlow">
	import iconCard from '@/components/ShortcutCard/index.vue'
	import flowJobApi from '@/api/flow/flowJobApi'
	import dtForm from '@/views/flow/dtform/index.vue'
	import preForm from '@/views/flow/dtform/pre_form.vue'
	const flows = ref()
	const dtFromRef = ref()
	const { proxy } = getCurrentInstance()
	const initFlow = () => {
		flowJobApi.flowUsables().then((data) => {
			flows.value = data
		})
	}
	initFlow()
	/**
	 * 发起申请
	 */
	const flowApply = (r) => {
		r.formTitle = r.flowTitle
		if (r.formType == '1') {
			proxy.$refs.preFormRef.onOpen(r)
		} else {
			dtFromRef.value.onOpen(r)
		}
	}
</script>
<style scoped>
	.allApply {
		width: 80%;
		display: flex;
	}
	.siggleAppy {
		width: 15%;
		height: 60px;
		display: flex;
		align-items: center;
	}
</style>
